<?php
namespace app\shop\home;

use app\shop\model\Live as LiveModel;
use app\shop\model\LiveList as LiveListModel;

use app\admin\model\Attachment;
/**
 * 创作直播
 */
class Live extends Common
{
    public function group()
    {
    	$where = array();

    	if(request()->param('id')){
    		$where['group_id'] = intval(request()->param('id'));
    	}
        $livelist = LiveModel::with('getimgpath')->where($where)->where('status',1)->select();

        $this->assign('artist', $livelist);

        if(isMobile()){
            return $this->fetch('Mobile/Live/group');
        }else{
            return $this->fetch();
        }
    }

    public function detail()
    {
    	$info = LiveModel::with('getimgpath')->where('id',request()->param('id'))->find();
        $list = LiveListModel::
        join('sp_admin_attachment photo','sp_shop_live_list.photo = photo.id','LEFT')
            ->where(['sp_shop_live_list.status'=>1,'sp_shop_live_list.live_id'=>request()->param('id')])
            ->order('sp_shop_live_list.sort desc')
            ->field('sp_shop_live_list.id,sp_shop_live_list.description,sp_shop_live_list.photo,photo.path,sp_shop_live_list.sort')
            ->select();
//        pr($list);exit;
    	//var_dump($info);die;
/*
    	$artwork = Artwork::with('getartist')->where('artist_id', $info['id'])->select();
        foreach ($artwork as $k => &$v) {
            $artistIn[] = $v['artist_id'];
            $in = explode(',', $v['photos']);
            for($i = 0; $i <count($in); $i++){
               $ins[] = Attachment::where('id',$in[$i])->value('path');
            }
             $v['img'] = $ins;
        }*/
    	//var_dump($info);die;
    	$this->assign('list', $list);
    	$this->assign('info', $info);
    	//$this->assign('artwork', $artwork);

        if(isMobile()){
            return $this->fetch('Mobile/Live/detail');
        }else{
            return $this->fetch();
        }
    }
}